<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<script type="text/javascript">
$("document").ready(function(){
	
	var params = $(app.popWin).data("data");
	
	params["data_type"] = "json";
	
	$("#changePwd").unbind("click").bind("click",function(){
		
		 var oldPwd=$("input[name='oldPassword']","#itemFormQz").val();
		 
		 var newPwd1=$("input[name='newPassword1']","#itemFormQz").val();
		 
		 var newPwd2=$("input[name='newPassword2']","#itemFormQz").val();
		 
		 params["oldPwd"] = oldPwd;
		 
		 params["newPwd1"] = newPwd1;
		 
		 params["ORGAN_ID"] = params.ID;
		 
		 if(newPwd1==''||newPwd1==null||$.trim(newPwd1)==''){
				
				$("#qzMsg").html("操作提示：新密码不能为空！");
				
				return false;
				
		 }
		 
		 if(newPwd1!=newPwd2){
			
			$("#qzMsg").html("操作提示：两次密码不一致！");
				
			return false;
			 
		 }
		 
		 $.post(basepath+"/admin/stamp/changePWD",params,function(data){
			 
			 if(data.success){
				 
				 util.alert("密码修改成功！",constant.ALERT_TYPE_SUCCESS);
				 
				 $("input[name='ORGAN_STAMP_PASSWORD']","#itemForm").val(newPwd1);
				 
				 app.popWins["popWin"].close();
				 
			 }else{
				 
				 $("#qzMsg").html("操作提示："+data.message);
				 
			 }
			 
		 });
		
	});

	jQuery.parser.parse("#organQzDiv");
	
});
</script>
<div id="organQzDiv" style="height:300px;margin:10px; width: 300px;">
	<form id="itemFormQz" class="core-form">
		<table>
			<c:if test="${!params.first}">
				<tr>
					<td>
			  			<div style="text-align:center;">旧密钥：</div>
			  		</td>
			  		<td>
			  			<input type="password" name="oldPassword">
			  		</td>
			  	</tr>
		  	</c:if>
		  	<tr>
		  		<td>
		  			<div style="text-align:center;">新密钥：</div>
		  		</td>
		  		<td>
			  		<input type="password"  name="newPassword1">
			  	</td>
		  	</tr>
		  	<tr>
		  		<td>
		  			<div style="text-align:center;">确认密钥：</div>
		  		</td>
		  		<td>
			  		<input type="password"  name="newPassword2">
			  	</td>
			</tr>
		  	<tr>
		  		<td colspan="2">
		  			<div style="text-align:center;"><a id="changePwd" class="core-button form-button" icon="icon-save">更改密钥</a></div>
		  		</td>
			</tr>
			<tr>
		  		<td height="25px" colspan="2">
		  			<div id="qzMsg" style="text-align:center;color: red;"></div>
		  		</td>
			</tr>
		</table>
	</form>
</div>